package com.dycong.common.leetcode.yi;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yilin
 * Date: 2019-08-12
 * Time: 15:27
 */
public class ItratorTest {
    public static void main(String[] args) {
        List<String> userNames = new CopyOnWriteArrayList<String>() {{
            add("Hollis");
            add("hollisA");
            add("HollisChuang");
            add("H");
        }};

        Iterator it = userNames.iterator();

        for (String userName : userNames) {
            if (userName.equals("hollisA")) {
                userNames.remove(userName);
            }
        }

        System.out.println(userNames);

        while (it.hasNext()) {
            System.out.println(it.next());
        }
    }
}
